require "TSLib"
local gamebid = "com.leiting.elona"
init(1)
mSleep(3000)
toast("欢迎使用触动精灵！")
w, h = getScreenSize() --获取分辨率
if w > h then
    dialog("请将模拟器设置为竖屏，建议分辨率：720x1280")
    lua_exit()
end
if w == 1080 and h == 1920 then
    lx0, ly0, rx0, ry0 = 300, 220, 1070, 300
    lx, ly, rx, ry = 0, 0, 1050, 70
elseif w == 720 and h == 1280 then
    lx0, ly0, rx0, ry0 = 10, 120, 710, 200
    lx, ly, rx, ry = 0, 0, 700, 80
elseif w == 640 and h == 1136 then
    lx0, ly0, rx0, ry0 = 10, 130, 630, 180
    lx, ly, rx, ry = 0, 0, 620, 40
elseif w == 1242 and h == 2208 then
    lx0, ly0, rx0, ry0 = 10, 200, 1232, 260
    lx, ly, rx, ry = 0, 0, 1222, 60
else
    dialog("脚本尚未完全适配您的手机分辨率，不保证运行效果")
    mSleep(3000)
end
glSettings({switch = "1001", x1 = lx0, y1 = ly0, x2 = rx0, y2 = ry0, tsp_switch = false})

function unlock() --防锁屏
    flag = deviceIsLock()
    if flag ~= 0 then
        sysver = getOSVer()
        sysint = tonumber(string.sub(sysver, 1, 1) .. string.sub(sysver, 2, 2))
        --转化为数字版本号
        if sysint == 10 then
            toast("解锁！", 1)
            pressHomeKey(0)
            pressHomeKey(1)
            mSleep(500)
            unlockDevice()
            mSleep(50)
            pressHomeKey(0)
            pressHomeKey(1)
            mSleep(500)
        else
            unlockDevice()
        end
    end
end

function gamestart()
    runApp(gamebid)
    mSleep(3000)
end

UINew("boom伊洛纳挂机辅助", "立即运行", "立即退出", "boom伊洛纳.dat", 0, 0)
-- UILabel("活动期间请勿使用和糖果颜色接近主题，以便提高收集效率!!!",24,"center","255,100,100")
-- UINew(2,"第一页,第二页","开始","取消","uiconfig.dat",0,120,w*0.8,h*0.8,"221,240,237","88,210,232")
UILabel("基础功能", 20, "center", "230,50,92")
UIRadio("basic", "搜索,召唤技能,魔法技能", "0")
UILabel("回蓝设置", 20, "center", "230,50,92")
UILabel("★ 蓝量少于_时停止使用技能，走动回蓝", 16, "left", "230,50,92")
UIRadio("backblue", "35,186", "0")
-- UILabel("脚本运行设置", 20, "center", "230,50,92")
-- UICombo(1, "select1", "下拉框1,下拉框2,下拉框3,下拉框4", "0")

-- UILabel({text="单选组合设置："})
-- UIRadio({id="radio",list="单选1,单选2,单选3,单选4,单选5,单选6"})
-- UILabel(2,"下拉框设置：")
-- UICombo({num=2,id="combo",list="下拉框1,下拉框2,下拉框3,下拉框4,下拉框5,下拉框6"})
-- UILabel("多选组合设置：")
-- UICheck("check1,check2,check3,check4,check5,check6","多选1,多选2,多选3,多选4,多选5,多选6")
-- UILabel("联动框设置：")
-- UIComboRlt("comborle,comborles","选项1,选项2,选项3","子选项1,子选项2,子选项3,子选项4#子选项5,子选项6,子选项7#子选项8,子选项9","test")
-- UILabel("关联框设置：")
-- UIComboRlts("comborles","test")
-- UIRadio("step","iPhone 6+,iPhone 5 或安卓旗舰,低配千元安卓机,选这个保证不卡,自定义速度","3")
-- UILabel("自定义速度设置",20,"center","230,50,92")
-- UIEdit("speedset","每秒点击次数","30",15,"left","255,0,0","number")
-- UILabel("是否显示准星",20,"center","230,50,92")
-- UIRadio("wztouch","显示,不显示","0")
-- UILabel("珊瑚设置",20,"center","230,50,92")
-- UIRadio("shanhu","孤独的珊瑚石,小珊瑚石","0")
-- UILabel("显示设置",20,"center","230,50,92")
-- UIRadio("case","全屏不显示菜单,石头界面,扩张界面","0")
-- UILabel("功能设置",20,"center","230,50,92")
-- UICheck("func1,func2,func3","升级石头,使用技能,收割农场","0@1")
UILabel("使用须知", 20, "left", "230,50,92")
UILabel("★ 如需吃东西请自行准备食腐装备，对应食物等", 16, "left", "230,50,92")
-- UILabel("★ 请将体积较大的鱼收起以便更容易找到红心。", 16, "left", "230,50,92")
-- UILabel("★ 每秒点击次数最好不要超过40次，否则游戏会卡死", 16, "left", "230,50,92")
-- UILabel("★ 活动期间建议使用全屏模式，半屏会导致有些鱼飘到上面去找不到", 16, "left", "230,50,92")
-- UILabel("★ 活动期间建议使用活动范围在珊瑚石周围的鱼比如小丑鱼", 16, "left", "230,50,92")
-- UILabel("★ 活动期间建议使用与活动物品色差较大的主题皮肤，否则会严重影响找色", 16, "left", "230,50,92")
-- UILabel("★游戏攻略、问题反馈请加群:414534539", 16, "left", "230,50,92")
UIShow()

if w == 640 and h == 1136 then
    require "5c"
elseif w == 1536 and h == 2048 then
    require "ipadhd"
elseif w == 750 and h == 1334 then
    require "6s"
elseif w == 1242 and h == 2208 then
    require "6P"
elseif w == 720 and h == 1280 then
    require "720p"
elseif w == 1080 and h == 1920 then
    require "1080p"
else
    setScreenScale(true, 720, 1280)
    require "720p"
    setScreenScale(false)
end
if basic == "下拉框2" then
    toast("1", 1)
end
while (true) do
    unlock()
    if frontAppBid() == gamebid then
        if basic == "搜索" then
            explore()
        elseif basic == "召唤技能" then
            call_elves(backblue)
        elseif basic == "魔法技能" then
            magic()
        end
    else
        gamestart()
    end
end
